var time = require("../../utils/time");
Page({

  data: {
    goods_id: null
  },
  onLoad: function (options) {
    this.requestData(options.id)
    this.setData({
      goods_id: options.id
    })
  },
  requestData(e) {
    var _this = this
    wx.showLoading({
      title: '加载中...',
    });
    getApp().request({
      url: getApp().api.crowdfund.details,
      method: "GET",
      data: {
        id: e
      },
      success(res) {
        wx.hideLoading()
        wx.setNavigationBarTitle({
          title: res.data.name
        })
        _this.setData({
          name: res.data.name,
          pic_list: res.data.pic_list,
          percent: res.data.percent,
          people_num: res.data.people_num,
          had_crowdfund_price: res.data.had_crowdfund_price,
          time: time.formatTimeTwo(res.data.crowdfund.end_time, 'm天h时'),
          detail: res.data.detail,
          is_favorite: res.data.user_collection,
          price: res.data.price,
          mch_info: res.data.mch_info,
          attr_group_list: res.data.attr_group_list,
          collection_count: res.data.collection_count
        })
      },
      fail(res) {
        console.log(res)
      }
    })
  },
  collect(e){
    this.requestData(e.detail)
  }
})